<?php //var_dump($this->cart->contents())?>

<br/>
<form id="frmpenjualan" action="<?php echo site_url('pembeliancontroller')?>" method="post">
    <div id="atas" style="width:100%;height:auto;padding:0;margin:0;">
        <div style="float:left;width:30%;">
        	<h3>BAJA INDAH SAKTI</h3>
        	<p>Tlp (0267) - 412873</p>
        	<p>FAX : 410738</p>
        	<p>KARAWANG
            </p>
        </div>
        <div style="float:left;width:35%;">
        	<table width="100%" style="border:3px solid black;">
            	<tr style="width:35px;text-align:center;">
                	<td style="border:1px solid black;"><strong>Supplier</strong></td>
                </tr>
                {kodepono}
                <tr style="width:35px;height:35px;">
                	<td><textarea rows="5" cols="50" style="resize:none;overflow:true;">{suppliername}</textarea></td>
                </tr>
                {/kodepono}
            </table>
        </div>
        <div style="float:right;width:25%;margin-left:25px;">
        	<h4>PESANAN PEMBELIAN</h4>
        	<table>
            	{kodepono}
            	<tr>
                	<td><strong>Tgl.PO</strong></td>
                    <td><strong>:</strong></td>
                    <td><?php echo date("d-M-Y");?></td>
               	</tr>
                <tr>
                	<td><strong>No.PO</strong></td>
                    <td><strong>:</strong></td>
                    <td><input id="nofaktur" name="nofaktur" type="text" class="flat-textbox"  value="{NoPo}" readonly="readonly"/></td>
               	</tr>
                {/kodepono}
            </table>
        </div>        
    </div><br/><br/><br/><br/><br/><br/><br/>
    
    <div id="tengah" style="width:95%;">
    
    </div>
    <br/>
    <table width="100%">
    	<thead class="tableCellHeader">
   	  <th width="10%">Kode Barang</th>
            <th width="20%">Deskripsi Barang</th>
            <th width="18%">Qty</th>
            <th width="17%">Harga Satuan</th>
            <th width="5%">Disc %</th>
            <th width="23%">Total Harga</th>
        <td width="7%"></thead>
        <tbody>        	
        	<?php
        		$i = 0;
				$totalall=0;
        		if(count($transpo) > 0){ 
					foreach($transpo as $items){	
									
						$style = "";
						if($i%2 == 0)$style="cellDefault"; else $style="cellAlternate";
						echo "<tr class=\"".$style."\">";
						echo "<td align=\"center\"><input id=\"txtkdbrg[]\" name=\"txtkdbrg[]\" type=\"text\" class=\"flat-textbox-string\" style=\"text-align:center;\" value=\"".$items->KodeDetailBarang."\" readonly=\"readonly\" /></td>";
						echo "<td align=\"center\"><input id=\"txtprdname[]\" name=\"txtprdname[]\" type=\"text\" class=\"flat-textbox-string\" style=\"text-align:center;\" value=\"".$items->Productname."\" readonly=\"readonly\" /></td>";
						echo "<td style=\"text-align:center;\"><input id=\"txtqty[]\" name=\"txtqty[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:right;\" value=\"".$items->Quantity."\" readonly=\"readonly\" />&nbsp;".$items->Typeunit."</td>";
						echo "<td style=\"text-align:center;\"><input id=\"txtitemprice[]\" name=\"txtitemprice[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:right;\" value=\"".$items->HargaBarang."\" readonly=\"readonly\" /></td>";
						$disc = isset($items->options['disc'])?$items->options['disc'] : 0;						
						echo "<td align=\"center\"><input id=\"txtdisc[]\" name=\"txtdisc[]\" type=\"text\" class=\"flat-textbox-string\" style=\"text-align:center;\" value=\"".$disc."\" readonly=\"readonly\" /></td>";
						$qty = 0;
						$harga = 0;
						$qty = intval($items->Quantity);
						$harga = intval($items->HargaBarang);
						$total = 0;
						if(intval($disc) != 0){
							$total = ($qty * $harga) - ((intval($disc) * ($qty * $harga))/100);
							$totalall = $totalall + $total;
						}else{
							$total = $qty * $harga;
							$totalall = $totalall + $total;
						}
						echo "<td style=\"text-align:center;\"><input id=\"txtTotal[]\" name=\"txtTotal[]\" type=\"text\" class=\"flat-textbox-number\" style=\"text-align:center;\" value=\"".$total."\" readonly=\"readonly\" /></td>";
						echo "<input type=\"hidden\" id=\"txtkodesupplier[]\" name=\"txtkodesupplier[]\" value=\"".$items->Kodesupplier."\" />";
						echo "<input type=\"hidden\" id=\"ttlamount[]\" name=\"ttlamount[]\" value=\"".$total."\" />";
						echo "</tr>";
						$i++;				
					}
        		}else{
        			echo "<tr><td colspan=\"6\" style=\"text-align:center;color:red;\">No Data To Display</td></tr>";
        		}
			?>
        </tbody>
        <tfoot>
        	<tr>
        		<td colspan="5" style="text-align:right;font-weight:bold;font-size:12pt;" class="flat-textbox-string">Subtotal</td>
        		<td style="text-align:center;font-size:1em;font-weight:bold;border:1px solid black;" class="flat-textbox-number"><?php echo intval($totalall)?></td>
        	</tr>
        </tfoot>
    </table>
</div>

    <div id="bawah"></div>
   <input type="submit" value="Print" id="btnSave" name="btnSave" >&nbsp;&nbsp;
   <a href="<?php echo site_url('pembeliancontroller');?>">BACK</a>
</form>